package alg;

import java.util.ArrayList;
import data.*;
import java.io.*;

public class ValidatorOutput
{
	private static final String OUTPUT_FILE = "drew_out.txt";
	public static void main(String[] args)
	{
		AlgorithmTester.run();
		ArrayList<Student> students = AlgorithmTester.courseProcessor.getGlobalStudents();
		ArrayList<Course> courses = AlgorithmTester.courseProcessor.getCourses();
		printData(students, courses);
		System.out.println(AlgorithmTester.getStatistics());
	}
	
	private static void printData(ArrayList<Student> students, ArrayList<Course> courses)
	{
		File f = new File(OUTPUT_FILE);
		PrintStream out = null;
		try
		{
			out = new PrintStream(f);
			for (Student s : students)
			{
				s.mrThibodeauxFormat(out, courses);
			}
		}
		catch (FileNotFoundException e)
		{	
			try
			{
				f.createNewFile();
				printData(students, courses);
			}
			catch (IOException ex)
			{
				System.err.println("Could not write output file.");
				ex.printStackTrace();
			}
		}
		catch (Exception e)
		{
			System.err.println("Unknown exception occured!");
			e.printStackTrace();
		}
		finally
		{
			if(out != null)
			{
				out.close();
			}
		}
	}
}
